package cn.dapeng.lambda;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @BelongProject study
 * @BelongPackage cn.dapeng.lambda
 * @Description TODO
 * @ClassName LambdaT04
 * @Author xupen
 * @Date 2024/7/31 14:45
 * @Version 1.0.0
 */
public class LambdaT04 {

    public static void main(String[] args) {
        int length = 100;
        Map<String, Student> map = new HashMap<>(length);
        for (int i = 0; i < length; i++) {
            Student s = new Student(i, "name" + i, i % 2 == 0);
            map.put(s.name() + "_" + s.id(), s);
        }

        List<String> list = map.values().stream().parallel()
                .filter(r -> r.id() > 500)
                .filter(Student::marry)
                .map(Student::name).toList();

        System.out.println(Arrays.toString(list.toArray()));

        String POST_URL = "http://%s:%s/ew%s";

        String x = POST_URL.formatted("host", "port", "/xxx");
        System.out.println(x);
    }
}

record Student(int id, String name, boolean marry) {

}
